<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../lib/vue-2.4.0.js"></script>
</head>

<body>
  <div id="app">
    <h2>{{count | filterEven}}</h2>
    <h2>{{count2 | filterEven}}</h2>
  </div>
</body>
<script>
  let app = new Vue({
    el: '#app',
    data: {
      count: 10,
      count2: 11
    },
    filters: {
      filterEven(num) {
        if (num % 2 === 0) {
          return num
        } else {
          return '非法数字'
        }
      }
    }
  })
</script>

</html>